(function(vc){

    vc.extends({
        propTypes: {
               callBackListener:vc.propTypes.string, //父组件名称
               callBackFunction:vc.propTypes.string //父组件监听方法
        },
        data:{
            addChainInoutOrderInfo:{
                orderId:'',
                csId:'',

            }
        },
         _initMethod:function(){

         },
         _initEvent:function(){
            vc.on('addChainInoutOrder','openAddChainInoutOrderModal',function(){
                $('#addChainInoutOrderModel').modal('show');
            });
        },
        methods:{
            addChainInoutOrderValidate(){
                return vc.validate.validate({
                    addChainInoutOrderInfo:$that.addChainInoutOrderInfo
                },{
                    'addChainInoutOrderInfo.csId':[
{
                            limit:"required",
                            param:"",
                            errInfo:"供应商ID不能为空"
                        },
 {
                            limit:"maxLength",
                            param:"32",
                            errInfo:"供应商ID不能为空"
                        },
                    ],




                });
            },
            saveChainInoutOrderInfo:function(){
                if(!$that.addChainInoutOrderValidate()){
                    vc.toast(vc.validate.errInfo);

                    return ;
                }

                $that.addChainInoutOrderInfo.communityId = vc.getCurrentCommunity().communityId;
                //不提交数据将数据 回调给侦听处理
                if(vc.notNull($props.callBackListener)){
                    vc.emit($props.callBackListener,$props.callBackFunction,$that.addChainInoutOrderInfo);
                    $('#addChainInoutOrderModel').modal('hide');
                    return ;
                }

                vc.http.apiPost(
                    'chainInoutOrder.saveChainInoutOrder',
                    JSON.stringify($that.addChainInoutOrderInfo),
                    {
                        emulateJSON:true
                     },
                     function(json,res){
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            $('#addChainInoutOrderModel').modal('hide');
                            $that.clearAddChainInoutOrderInfo();
                            vc.emit('chainInoutOrderManage','listChainInoutOrder',{});

                            return ;
                        }
                        vc.toast(_json.msg);

                     },
                     function(errInfo,error){
                        console.log('请求失败处理');

                        vc.toast(errInfo);

                     });
            },
            clearAddChainInoutOrderInfo:function(){
                $that.addChainInoutOrderInfo = {
                                            csId:'',

                                        };
            }
        }
    });

})(window.vc);
